import request from '@/utils/request'

// 查询PLC缓存列表
export function listCache(query) {
  return request({
    url: '/plc/cache/list',
    method: 'get',
    params: query
  })
}

// 查询PLC缓存列表(分页)
export function pageCache(query) {
  return request({
    url: '/plc/cache/page',
    method: 'get',
    params: query
  })
}

// 查询PLC缓存详细
export function getCache(code) {
  return request({
    url: '/plc/cache/get/' + code,
    method: 'get'
  })
}

export function getCacheByTag(tag) {
  return request({
    url: '/plc/cache/getTag/' + tag,
    method: 'get'
  })
}

// 新增PLC缓存
export function addCache(data) {
  return request({
    url: '/plc/cache/add',
    method: 'post',
    data: data
  })
}

// 修改PLC缓存
export function updateCache(data) {
  return request({
    url: '/plc/cache/edit',
    method: 'post',
    data: data
  })
}

// 删除PLC缓存
export function delCache(id) {
  return request({
    url: '/plc/cache/remove/' + id,
    method: 'post'
  })
}


export function getHisStatusListByCode(query) {
  return request({
    url: '/plc/cache/getHisStatusListByCode',
    method: 'get',
    params: query
  })
}

export function getHisColListByCode(query) {
  return request({
    url: '/plc/cache/getHisColListByCode',
    method: 'get',
    params: query
  })
}

export function getHisTableOption() {
  return request({
    url: '/plc/cache/getHisTableOption',
    method: 'get'
  })
}

export function pageHisTable(query) {
  return request({
    url: '/plc/cache/pageHisTable',
    method: 'get',
    params: query
  })
}

export function updateSaveStrategy() {
  return request({
    url: '/plc/cache/updateSaveStrategy',
    method: 'post'
  })
}

export function getTagOption() {
  return request({
    url: '/plc/cache/getTagOption',
    method: 'get'
  })
}

export function exportCache(query) {
  return request({
    url: '/plc/cache/export',
    method: 'get',
    params: query
  })
}

export function exportHisTable(query) {
  return request({
    url: '/plc/cache/exportHisTable',
    method: 'get',
    params: query
  })
}

export function getHisChart(query) {
  return request({
    url: '/plc/cache/getHisChart',
    method: 'get',
    params: query
  })
}

/**
 * tags支持多个标签，用英文逗号分隔
 * connector为or时，表示标签之间是或者关系，否则为合并关系
 */
export function getRealDataByTags(tags, connector) {
  return request({
    url: '/plc/cache/getRealDataByTags',
    method: 'get',
    params: {tags, connector}
  })
}

export function getRedisCache() {
    return request({
        url: '/plc/cache/getRedisCache',
        method: 'get'
    })
}

export function getRedisCacheByCodes(data) {
    return request({
        url: '/plc/cache/getRedisCacheByCodes',
        method: 'post',
        params: data
    })
}

export function getDataByCode(data) {
  return request({
    url: '/plc/cache/getDataByCode',
    method: 'post',
    data: data
  })
}

export function getMixingDataNow(query) {
  return request({
    url: '/plc/cache/getMixingDataNow',
    method: 'get',
    params: query
  })
}

export function getSurveyDataNow(query) {
  return request({
    url: '/plc/cache/getSurveyDataNow',
    method: 'get',
    params: query
  })
}

export function getSiloDataNow(query) {
  return request({
    url: '/plc/cache/getSiloDataNow',
    method: 'get',
    params: query
  })
}

export function getFlueDataNow(query) {
  return request({
    url: '/plc/cache/getFlueDataNow',
    method: 'get',
    params: query
  })
}

export function getColdDataNow(query) {
  return request({
    url: '/plc/cache/getColdDataNow',
    method: 'get',
    params: query
  })
}

